package top.kaoshanji.ch05;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.ch05.enums.Size;

import java.util.Scanner;

/**
 * 代码清单 ch05-03：枚举示例
 * @see top.kaoshanji.ch05.enums.Size
 * author kaoshanji
 * ^_^
 * create time 2024/11/26 14:03
 */
public class EnumTest {

    private static final Logger logger = LogManager.getLogger(EnumTest.class);

    public static void main(String[] args) {
        logger.info("...代码清单 ch05-03：枚举示例...");

        var in = new Scanner(System.in);
        System.out.print("Enter a size: (SMALL, MEDIUM, LARGE, EXTRA_LARGE) ");
        String input = in.next().toUpperCase();

        Size size = Enum.valueOf(Size.class, input);
        System.out.println("size=" + size);
        System.out.println("abbreviation=" + size.getAbbreviation());
        if (size == Size.EXTRA_LARGE) {
            System.out.println("Good job--you paid attention to the _.");
        }

    }

}
